import Vue from 'vue'
import VueRouter from 'vue-router'

import {ais, VueAIS} from './utils/ais.js'

Vue.use(VueAIS)

Vue.directive('ais-page', {
  params: ['page-name'],
  bind: function () {
    if (this.el.__vue__ === undefined) {
      console.error('ais-page vue is undefine ' + this)
    } else {
      this.el.__vue__.$pageName = this.params.$pageName
      ais.addvm(this.params.pageName, this.el.__vue__)
    }
  },
  unbind: function () {
    ais.remove(this.params.pageName)
  }
})

import App from './App'

Vue.use(VueRouter)

var router = new VueRouter()
var app = Vue.extend(App)
ais.router = router

router.map({
  '/pwr': {
    component: require('./pages/pwr.vue')
  }
})

router.start(app, '#app')
